import request from '@/utils/request'

/**
 * 新建逾期
 * @param {*} data
 */
export function crmOverdueSaveAPI(data) {
  const url = data.entity && data.entity.refundId ? 'update' : 'add'
  return request({
    url: 'crmOverdue/' + url,
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 逾期列表
 * @param {*} data
 */
export function crmOverdueIndexAPI(data) {
  return request({
    url: 'crmOverdue/queryPageList',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 删除
 * @param {*} data
 *
 */
export function crmOverdueDeleteAPI(data) {
  return request({
    url: 'crmOverdue/deleteByIds',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 逾期详情
 * @param {*} data
 */
export function crmOverdueReadAPI(data) {
  return request({
    url: `crmOverdue/queryById/${data.id}`,
    method: 'post'
  })
}

/**
 * 逾期列表
 * @param {*} data
 *
 */
export function crmOverdueFileListAPI(data) {
  return request({
    url: 'crmOverdue/queryFileList',
    method: 'post',
    data: data
  })
}

/**
 * tab数量
 * @param {*} data
 *
 */
export function crmOverdueNumAPI(data) {
  return request({
    url: 'crmOverdue/num',
    method: 'post',
    data: data
  })
}

/**
 * 导出
 * @param {*} data
 */
export function crmOverdueExcelExportAPI(data) {
  return request({
    url: 'crmOverdue/batchExportExcel',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    responseType: 'blob',
    timeout: 60000
  })
}

export function crmOverdueExcelAllExportAPI(data) {
  return request({
    url: 'crmOverdue/allExportExcel',
    method: 'post',
    data: data,
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 转移
 * @param {*} data
 */
export function crmOverdueTransferAPI(data) {
  return request({
    url: 'crmOverdue/changeOwnerUser',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 转移
 * @param {*} data
 */
 export function crmOverdueOverdueAPI(data) {
  return request({
    url: 'crmOverdue/changeOverdue',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 转移
 * @param {*} data
 */
 export function crmQueryOverdueAPI(data) {
  return request({
    url: 'crmOverdue/queryOverdueStatus',
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function crmOverdueFindAPI(data) {
  return request({
    url: 'crmOverdue/showCustomerAndContract',
    method: 'post',
    data: data,
  })
}

export function crmOverdueDownloadExcelAPI(data) {
  return request({
    url: 'crmOverdue/downloadExcel',
    method: 'post',
    data: data,
    responseType: 'blob'
  })
}

export function crmOverdueExcelImportAPI(data) {
  var param = new FormData()
  Object.keys(data).forEach(key => {
    param.append(key, data[key])
  })
  return request({
    url: 'crmOverdue/uploadExcel',
    method: 'post',
    data: param,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}
